当前位置:  开发笔记 > 编程语言 > 正文

Cocoapods | podspec将GoogleAnalytics添加为依赖项

如何解决《Cocoapods|podspec将GoogleAnalytics添加为依赖项》经验,为你挑选了0个好方法。

我正在尝试将GoogleAnalytics添加为我的podspec中的依赖项,如下所示:

s.dependency "GoogleAnalytics"

我当然得到:

'Pods - ****'目标具有传递依赖关系,包括静态二进制文件:(****/Pods/GoogleAnalytics/Libraries/libGoogleAnalytics.a)

由于谷歌并不打算给他们的pod动态版本,我试图通过在podspec中添加source_files/public_header_files/vendored_frameworks来添加它:

s.subspec 'GoogleAnalytics' do |sp|
  sp.source_files =
    'Pods/Google/Headers/*.h',
    'Pods/Google/Headers/ModuleHeaders/*.h',
    'Pods/FirebaseAnalytics/Frameworks/frameworks/FirebaseAnalytics.framework/Headers/*.h',
    'Pods/FirebaseInstanceID/Sources/*.h',
    'Pods/FirebaseInstanceID/Frameworks/frameworks/FirebaseInstanceID.framework/Headers/*.h',
    'Pods/GoogleInterchangeUtilities/Frameworks/frameworks/GoogleInterchangeUtilities.framework/Headers/*.h',
    'Pods/GoogleSymbolUtilities/Frameworks/frameworks/GoogleSymbolUtilities.framework/Headers/*.h',
    'Pods/GoogleToolboxForMac/*.h',
    'Pods/GoogleToolboxForMac/Foundation/*.h',
    'Pods/GoogleToolboxForMac/Foundation/*.m',
    'Pods/GoogleAnalytics/Libraries/*.a',
    'Pods/GoogleAnalytics/Sources/*.h'

  sp.ios.public_header_files  =
    'Pods/Google/Headers/*.h',
    'Pods/Google/Headers/ModuleHeaders/*.h',
    'Pods/FirebaseAnalytics/Frameworks/frameworks/FirebaseAnalytics.framework/Headers/*.h',
    'Pods/FirebaseInstanceID/Source/*.h',
    'Pods/FirebaseInstanceID/Frameworks/frameworks/FirebaseInstanceID.framework/Headers/*.h',
    'Pods/GoogleInterchangeUtilities/Frameworks/frameworks/GoogleInterchangeUtilities.framework/Headers/*.h',
    'Pods/GoogleSymbolUtilities/Frameworks/frameworks/GoogleSymbolUtilities.framework/Headers/*.h',
    'Pods/GoogleToolboxForMac/*.h',
    'Pods/GoogleToolboxForMac/Foundation/*.h',
    'Pods/GoogleAnalytics/Sources/*.h'

  sp.ios.vendored_frameworks =
    'Pods/Google/Frameworks/GGLAnalytics.framework',
    'Pods/Google/Frameworks/GGLCore.framework',
    'Pods/FirebaseAnalytics/Frameworks/frameworks/FirebaseAnalytics.framework',
    'Pods/FirebaseCore/Frameworks/frameworks/FirebaseCore.framework',
    'Pods/FirebaseInstanceID/Frameworks/frameworks/FirebaseInstanceID.framework',
    'Pods/GoogleInterchangeUtilities/Frameworks/frameworks/GoogleInterchangeUtilities.framework',
    'Pods/GoogleSymbolUtilities/Frameworks/frameworks/GoogleSymbolUtilities.framework'
end

我在我的项目中得到类似的东西:

pod"MyPod"

在此输入图像描述

我在我的Bridging-Header中有这个:

#import 
#import 
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"

我尝试在AppDelegate中执行此操作:

// Configure tracker from GoogleService-Info.plist.
    var configureError:NSError?
    GGLContext.sharedInstance().configureWithError(&configureError)
    assert(configureError == nil, "Error configuring Google services: \(configureError)")

        let gai = GAI.sharedInstance()
        gai?.trackUncaughtExceptions = true  // report uncaught exceptions
        gai?.logger.logLevel = GAILogLevel.verbose  // remove before app release

我仍然收到以下错误:

"_OBJC_CLASS _ $ _ GAI",引自:AppDelegate.o中的objc-class-ref ld:找不到架构x86_64 clang的符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)

有没有人试过这样做?你成功了吗?谢谢

推荐阅读
wurtjq
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有